package com.program.facesigninsystem.dao;

import com.program.facesigninsystem.entity.Product;
import com.program.facesigninsystem.entity.Rewards;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface IRewardsDao {
    /***
     * 查询积分记录
     * @param uid
     * @return
     */
    Rewards selectReward(@Param("uid")String uid);

    /***
     * 新增积分记录
     * @param uid
     * @param limit_from_record_a
     * @param limit_from_record_b
     * @param limit_from_record_c
     * @param limit_from_record_activity
     * @param last_gain_day
     * @param reward_points
     */
    void addNewRewards(
            @Param("uid")String uid,
            @Param("limit_from_record_a")int limit_from_record_a,
            @Param("limit_from_record_b")int limit_from_record_b,
            @Param("limit_from_record_c")int limit_from_record_c,
            @Param("limit_from_record_activity")int limit_from_record_activity,
            @Param("last_gain_day")String last_gain_day,
            @Param("reward_points")int reward_points,
            @Param("day_reward")int day_reward
            );

    /***
     * 更新积分记录
     * @param uid
     * @param limit_from_record_a
     * @param limit_from_record_b
     * @param limit_from_record_c
     * @param limit_from_record_activity
     * @param last_gain_day
     * @param reward_points
     */
    void updateRewards(
            @Param("uid")String uid,
            @Param("limit_from_record_a")int limit_from_record_a,
            @Param("limit_from_record_b")int limit_from_record_b,
            @Param("limit_from_record_c")int limit_from_record_c,
            @Param("limit_from_record_activity")int limit_from_record_activity,
            @Param("last_gain_day")String last_gain_day,
            @Param("reward_points")int reward_points,
            @Param("day_reward")int day_reward
    );

    /***
     * 新增商品
     * @param id
     * @param name
     * @param price
     * @param caption
     * @param imageUrl
     * @param storage
     * @param total
     */
    void addNewProducts(
            @Param("id")String id,
            @Param("name")String name,
            @Param("price")int price,
            @Param("caption")String caption,
            @Param("imageUrl")String imageUrl,
            @Param("storage")int storage,
            @Param("total")int total
    );

    /***
     * 更新是否显示
     * @param show
     * @param id
     */
    void updateProductShow(@Param("show")int show,@Param("id")String id);

    /***
     * 更新商品库存
     * @param id
     * @param storage
     */
    void updateProductsStorage(
            @Param("id")String id,
            @Param("storage")int storage
    );

    /***
     * 查询所有商城物品
     * @return
     */
    List<Product> selectAllProducts();

    /***
     * 查询显示的商品
     * @return
     */
    List<Product> selectAllProductsShow();

    /***
     * 按商品id查询商城物品库存
     * @return
     */
    Map<String,Integer> selectProductById(@Param("id")String id);
    /***
     * 新增兑换商品记录
     * @param id
     * @param uid
     * @param name
     * @param phone
     * @param createTime
     * @param province
     * @param city
     * @param address
     * @param pid
     * @param state
     */
    void addNewRedeemRecord(
            @Param("id")String id,
            @Param("uid")String uid,
            @Param("name")String name,
            @Param("phone")String phone,
            @Param("createTime")String createTime,
            @Param("province")String province,
            @Param("city")String city,
            @Param("address")String address,
            @Param("pid")String pid,
            @Param("state")int state
    );

    /***
     * 更新发货状态
     * @param id
     * @param state
     */
    void updateRedeemRecordState(
            @Param("id")String id,
            @Param("state")int state
    );

    /***
     * 查询所有兑换记录
     * @return
     */
    List<Map<String,Object>> selectAllRedeemRecord();

    /***
     * 查询待发货记录
     * @return
     */
    List<Map<String,Object>> selectRecordNotSend();

    /***
     * 查询已发货记录
     * @return
     */
    List<Map<String,Object>> selectRecordAlreadySend();

    /***
     * 按用户id查询发货记录
     * @param uid
     * @return
     */
    List<Map<String,Object>> selectMyRedeemRecord(
            @Param("uid")String uid
    );
}
